<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <jsp:include page="../common/header.jsp" />
    <script type="text/javascript">
        function saveScore() {
            digit = /^\d+(\.\d+)?$/;//匹配非负浮点数
            $saveScore = $("input[name=saveScore]");
            var courseScore = parseInt($("#courseScore").text());

            $saveScore.bind("click", function () {
                var resultFlag = true;
                $("input[name=score]").each(function (index) {
                    if ($.trim($(this).val()) == "" || !digit.test($(this).val())) {
                        $(this).css({border: "solid 2px #f00"});
                        resultFlag = false;
                    }
                    else if ($(this).val() > courseScore) {
                        $(this).css({border: "solid 2px #f00"});
                        resultFlag = false;
                    }
                    else {
                        $(this).css({border: ""});
                    }
                });
                if (true == resultFlag) {
                    $("#form1").submit();
                }
                else {
                    alert("成绩输入有错误，请核对后再提交");
                }
            });
        }
        $(function () {
            saveScore();
        });
    </script>
    <jsp:include page="../common/mycss.jsp" />
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">
            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <jsp:include page="../common/title.jsp" />
            </div>
            <div class="lyear-layout-sidebar-scroll">
                <jsp:include page="../common/menu.jsp" />
            </div>
        </aside>
        <!--End 左侧导航-->
        <jsp:include page="../common/top.jsp" />
        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <h5>成绩管理——成绩录入</h5>
                            </div>
                            <div class="card-body">
                                <div id="accordion">
                                    <div align="center">
                                        班级：<s:property value="grade.year"/>届<s:property value="grade.name"/> （<s:property value="grade.classID"/>）班
                                        &nbsp;&nbsp;-&nbsp;&nbsp;
                                        学期：<s:property value="xueqi"/>
                                        &nbsp;&nbsp;-&nbsp;&nbsp;
                                        考试类型：<s:property value="examType"/>
                                        &nbsp;&nbsp;-&nbsp;&nbsp;
                                        课程：<s:property value="course.name"/>
                                        &nbsp;&nbsp;-&nbsp;&nbsp;
                                        满分：<span id="courseScore"><s:property value="course.score"/></span>
                                        &nbsp;&nbsp;-&nbsp;&nbsp;
                                        授课教师：<s:property value="teacherName"/>
                                        <hr/>
                                        <form action="scoreRecordFinish.action" method="post" id="form1">
                                            <input type="hidden" name="gradeID" value='<s:property value="grade.bianHao"/>'>
                                            <input type="hidden" name="courseID" value='<s:property value="course.bianHao" />'/>
                                            <input type="hidden" name="xueqi" value='<s:property value="xueqi" />'/>
                                            <input type="hidden" name="examType" value='<s:property value="examType" />'>
                                            <table class="datalist">
                                                <tr>
                                                    <th colspan="3" align="left"> 考试时间 ：<input style="color: black" type="text" name="examTime"
                                                                                               value='<s:property value="currentDate" />'/></th>
                                                </tr>
                                                <tr>
                                                    <th><strong>学&nbsp;&nbsp;&nbsp;&nbsp;号</strong></th>
                                                    <th><strong>姓&nbsp;&nbsp;&nbsp;&nbsp;名</strong></th>
                                                    <th><strong>考试成绩</strong></th>
                                                </tr>
                                                <s:iterator value="subStudents">
                                                    <tr>
                                                        <td><s:property value="xuehao"/></td>
                                                        <td><s:property value="stuName"/></td>
                                                        <td><input type="hidden" name="stuXueHao" value='<s:property value="xuehao" />'/><input
                                                                type="hidden" name="stuName" value='<s:property value="stuName" />'/> <input type="text"
                                                                                                                                             name="score"
                                                                                                                                             value="0"/>
                                                        </td>
                                                    </tr>
                                                </s:iterator>
                                                <tr>
                                                    <td colspan="3" align="center"><input type="button" name="saveScore" value="保存成绩"/> <input
                                                            type="reset" value="取消操作"/></td>
                                                </tr>
                                            </table>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>
</body>
</html>
